/**
 * <p>Title: 客户端静态方法的定义</p>
 * <p>Description: 所有涉及客户端全局使用的静态方法均在此类中定义，一般情况使用静态方法。
 * 由于静态方法和变量会在整个生命周期占用内存，因此此类的方法应尽量做到少而精</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: dc</p>
 * @author 高艳芝
 * @version 1.0
 *
 *
 * 修改日期:2004-11-15
 * 修改人:高艳芝
 * 修改内容:增加判断email地址，分割字符串的方法
 *
 * 修改日期:2004-11-16
 * 修改人:高艳芝
 * 修改内容:增加判断变量值、变量缺省值的方法
 *
 * 修改日期:2006-10-25
 * 修改人:高艳芝
 * 修改内容:
 *     1.针对bs改造添加\改写一些方法
 *     2.去掉log属性，因为bs中不能写log，而且取得log对象的方式在bs也抛异常
 *     3。读写本地配置文件的方法也删除
 */

package com.dc.trans.steps.bwzh.common;

import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Window;
import java.io.File;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.ImageIcon;


public class Util {
  // <!--  add by gaoyanzhi, 20061025, access remote resource
  public static Map mapNodeMeta = null;
  //  add by gaoyanzhi, 20061025, access remote resource --------->

  public final static boolean support_oracle8i_clob = true;




  /**
   * 判断字符串是否为空
   * @param str
   * @return
   */
  public static final String CheckNull(String str) {
    if (str == null) {
      return "";
    }
    return str;
  }

  /**
   * This method will replace '&amp;' with &quot&amp;amp;&quot, '&quot' with
   * &quot&amp;quot;&quot, '&lt;' with &quot&amp;lt;&quot and '&gt;' with
   * &quot&amp;gt;&quot.
   */
  public static String doHTMLEncode(String s) {
    char[] specChars = new char[5];
    String[] specCharsRepl = new String[5];
    specChars[0] = '&';
    specCharsRepl[0] = "amp;"; //escapeChar
    specChars[1] = '"';
    specCharsRepl[1] = "quot;";
    specChars[2] = '<';
    specCharsRepl[2] = "lt;";
    specChars[3] = '>';
    specCharsRepl[3] = "gt;";
    specChars[4] = ' ';
    /*specCharsRepl[4] = "nbsp;";
     specChars[5] = '(';
     specCharsRepl[5] = "#40;";
     specChars[6] = ')';
     specCharsRepl[6] = "#41;";*/
    return replSpecChars(s, specChars, specCharsRepl, '&');
  }

  private static String replSpecChars(
      String input,
      char[] specChars,
      String[] specCharsRepl,
      char firstChar) {
    String out = null;
    if (input != null) {
      StringBuffer output = new StringBuffer(input);
      for (int i = 0; i < specChars.length; i++) {
        int index = output.toString().indexOf(specChars[i]);
        while (index != -1) {
          output.setCharAt(index, firstChar);
          output.insert(index + 1, specCharsRepl[i]);
          index =
              output.toString().indexOf(
              specChars[i],
              index + 1 + specCharsRepl[i].length());
        }
      }
      out = output.toString();
    }
    return out;
  }

  /**
   * 取得当前日期时间，格式为yyyy-MM-dd HH:mm:ss
   * @return
   */
  public static String getCurrentDateTime()
  {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date());
  }
  /**
   * 将给定时间字符串格式化为yyyy-MM-dd HH:mm:ss格式
   * @param dateString给定字符串，格式为yyyyMMddHHmmss
   * @return
   */
  public static String MakeFmtDate(String dateString) {
    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    try{
      return sdf1.format(sdf.parse(dateString));
    }catch(Exception err){}
    return dateString;
  }

  /**
   * 将给定字符串格式化为xxx.xxx.xxx.xxx形式
   * @param _text
   * @return
   */
  public static String formatIPText(String _text) {
    int iLength = _text.length();
    if (iLength == 15) {
      return _text;
    }
    StringBuffer oBuffer = new StringBuffer(15);
    int iSegmentLength = 0;
    for (int i = 0; i < iLength; i++) {
      char c = _text.charAt(i);
      if (c == '.') {
        if (iSegmentLength < 3) {
          for (int j = iSegmentLength; j < 3; j++) {
            oBuffer.append(' ');
          }
        }
        oBuffer.append('.');
        iSegmentLength = 0;
      }
      else {
        oBuffer.append(c);
        iSegmentLength++;
      }
    }
    iLength = oBuffer.length() + 1;
    for (int i = iLength; i < 16; i++) {
      oBuffer.append(' ');
    }
    return (new String(oBuffer));
  }
  /**
   * mend by fang 2004-10-25 由于分离后的每个字符串没有进行trim(),设置查询结果表格数据列时
   * 带空格,导致数据无法获取,现在加上trim处理
   */
  public static String[] toStrings(String value, String delim) {
    StringTokenizer st = null;
    if (delim == null) {
      st = new StringTokenizer(value);
    }
    else {
      st = new StringTokenizer(value, delim);
    }
    int k = st.countTokens();
    if (k == 0) {
      return null;
    }

    String[] param = new String[k];
    k = 0;
    String str="";
    while (st.hasMoreTokens()) {
      str=st.nextToken();
      if(str!=null)
        str=str.trim();
      param[k] = str;
      k++;
    }
    return param;
  }

  /**
   * 取得今天的日期时间
   * @return
   */
//  public static String getToday() {
//    return getToday(true);
//  }

  /**
   * 取得今天的日期时间
   * @param bflag，true，返回yyyy-MM-dd HH:mm:ss；false，返回yyyy-MM-dd
   * @return
   */
//  public static String getToday(boolean bflag) {
//    try
//    {
//      return getWorkFlowServer().getToday(bflag);
//    }
//    catch (Exception ex) {
//      ex.printStackTrace();
//      return null;
//    }
//
////    String dbtime = com.digitalchina.dcflexwork.common.util.DateUtil.getDBTime();
////    if (bflag) {
////      return dbtime;
////    }
////    else {
////      return dbtime.substring(0, 10);
////    }
//
////    Date _date = new Date();
////    DateFormat formatt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
////                                              Locale.CHINA);
////    //String m_DateTime = formatt.format(_date);
////    String m_DateTime = formatt.format(_date);
////    if (bflag) {
////      return m_DateTime;
////    }
////    else {
////      return m_DateTime.substring(0, 10);
////    }
//  }

//  /**
//   * 取得从今天开始，指定年、月、日、时、分、秒差值的时间
//   * @param iYear
//   * @param iMonth
//   * @param idate
//   * @param ihour
//   * @param iminute
//   * @param isecond
//   * @return
//   */
//  public static String getDiffToDay(int iYear, int iMonth, int idate,
//                                    int ihour, int iminute, int isecond) {
//    return getDiffTime(getToday(), iYear, iMonth, idate, ihour, iminute,
//                       isecond, true);
//  }
//  /**
//   * 取得从今天开始，指定年、月、日、时、分、秒差值的时间
//   * @param iYear
//   * @param iMonth
//   * @param idate
//   * @param ihour
//   * @param iminute
//   * @param isecond
//   * @param bflag
//   * @return
//   */
//  public static String getDiffToDay(int iYear, int iMonth, int idate,
//                                    int ihour, int iminute, int isecond,
//                                    boolean bflag) {
//    return getDiffTime(getToday(), iYear, iMonth, idate, ihour, iminute,
//                       isecond, bflag);
//  }

  /**
   * 取得从今天开始，指定年、月、日、时、分、秒差值的时间
   * @param oldtime
   * @param iYear
   * @param iMonth
   * @param idate
   * @param ihour
   * @param iminute
   * @param isecond
   * @param bflag true，返回返回yyyy-MM-dd HH:mm:ss；false，返回yyyy-MM-dd
   * @return
   */
  public static String getDiffTime(String oldtime,
                                   int iYear, int iMonth, int idate,
                                   int ihour, int iminute, int isecond,
                                   boolean bflag) {
    int year = Integer.parseInt(oldtime.substring(0, 4)) - 1900;
    int month = Integer.parseInt(oldtime.substring(5, 7));
    int day = Integer.parseInt(oldtime.substring(8, 10));
    int hh = 0;
    int mm = 0;
    int ss = 0;
    if (bflag) {
      hh = Integer.parseInt(oldtime.substring(11, 13));
      mm = Integer.parseInt(oldtime.substring(14, 16));
      ss = Integer.parseInt(oldtime.substring(17, 19));
    }
    Date _date = new Date(year, month, day, hh, mm, ss);

    _date.setYear(_date.getYear() + iYear);
    _date.setMonth(_date.getMonth() + iMonth - 1);
    _date.setDate(_date.getDate() + idate);
    _date.setHours(_date.getHours() + ihour);
    _date.setMinutes(_date.getMinutes() + iminute);
    _date.setSeconds(_date.getSeconds() + isecond);

    DateFormat formatt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
                                              Locale.CHINA);
    String m_DateTime = formatt.format(_date);
    if (bflag) {
      return m_DateTime;
    }
    else {
      return m_DateTime.substring(0, 10);
    }
  }

  public static long IPToLong(String strIP1) {
    try {
      int nPos11 = strIP1.indexOf(".", 0);
      int nPos12 = strIP1.indexOf(".", nPos11 + 1);
      int nPos13 = strIP1.indexOf(".", nPos12 + 1);
      String strIP11 = strIP1.substring(0, nPos11).trim();
      String strIP12 = strIP1.substring(nPos11 + 1, nPos12).trim();
      String strIP13 = strIP1.substring(nPos12 + 1, nPos13).trim();
      String strIP14 = strIP1.substring(nPos13 + 1).trim();
      if ( strIP11 == null ) strIP11="0";
      if ( strIP12 == null ) strIP12="0";
      if ( strIP13 == null ) strIP13="0";
      if ( strIP14 == null ) strIP14="0";

      int nIP11 = Integer.parseInt(strIP11);
      int nIP12 = Integer.parseInt(strIP12);
      int nIP13 = Integer.parseInt(strIP13);
      int nIP14 = Integer.parseInt(strIP14);
      return (nIP11*255*255*255+nIP12*255*255+nIP13*255+nIP14);
    }
    catch (Exception ex) {
      return 0;
    }
  }
  public static String toChinese(String strvalue){
      try{
          if(strvalue==null)
              return null;
          else{
              strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
              return strvalue;
          }
      }catch(Exception e){
          return null;
      }
  }

  /**
   * Center a window on Desktop
   */
  public static void centerWindowOnDeskTop(Window window)
  {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = window.getSize();

    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }

    window.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
  }

  /**
   * 将以某个符号分割的各值转换成字符串数组形式
   * @param strSource 源字符串
   * @param strFlag 分隔标志
   * @return 字符串数组
   */
  public static String[] transToStrArray(String strSource, String strFlag) {
    String[] strReturn;
    int nCount = 0;
    int nPos1 = 0, nPos2 = 0;
    String strTemp = null;
    while (strSource.indexOf(strFlag, nPos1) > 0) {
      nPos2 = strSource.indexOf(strFlag, nPos1);
      nPos1 = nPos2 + 1;
      nCount++;
    }
    strReturn = new String[nCount + 1];
    nPos1 = 0;
    nPos2 = 0;
    nCount = 0;
    strTemp = null;
    while (strSource.indexOf(strFlag, nPos1) > 0) {
      nPos2 = strSource.indexOf(strFlag, nPos1);
      strTemp = strSource.substring(nPos1, nPos2);
      strReturn[nCount] = strTemp.trim();
      nPos1 = nPos2 + 1;
      nCount++;
    }
    strReturn[nCount] = strSource.substring(nPos1);
    return strReturn;
  }
  /**
   * 邮箱合法性检查
   *
   */
   public static boolean IsEMailAddress(String theEmail) {
    if ( (theEmail == null) || (theEmail.length() == 0)) {
      return true;
    }
    else if (theEmail.length() > 78) {
      // email地址长度控制
      return false;
    }
    else {

      if (theEmail.charAt(theEmail.length() - 1) == '.') {
        theEmail = theEmail.substring(0, theEmail.length() - 1);
      }

      //@标记
      int atIndex = theEmail.indexOf('@');
      if (atIndex < 0) {
        return false;
      }
      //字符合法性检查
      String mailbox = theEmail.substring(0, atIndex);
      if (mailbox == null || mailbox.length() == 0) {
        return false;
      }
      else {
        int oldDotIndex = 0;
        int dotEnd = mailbox.indexOf('.', oldDotIndex);
        boolean done = false;
        do {
          //
          if (dotEnd == oldDotIndex) {
            return false;
          }
          if (dotEnd < 0) {
            dotEnd = mailbox.length();
            done = true;
          }
          for (int i = oldDotIndex; i < dotEnd; i++) {
            char cur = mailbox.charAt(i);
            if (!Character.isLetter(cur) &&
                !Character.isDigit(cur) &&
                cur != '!' && cur != '#' &&
                cur != '$' && cur != '%' &&
                cur != '&' && cur != '\'' &&
                cur != '*' && cur != '+' &&
                cur != '-' && cur != '/' &&
                cur != '=' && cur != '?' &&
                cur != '^' && cur != '_' &&
                cur != '`' && cur != '{' &&
                cur != '|' && cur != '}' &&
                cur != '~') {
              return false;
            }
          }
          oldDotIndex = dotEnd + 1;
          dotEnd = mailbox.indexOf('.', oldDotIndex + 1);
        }
        while (!done);
      }
      //域检查
      String domain = theEmail.substring(atIndex + 1);
      if (domain == null || domain.length() == 0) {
        return false;
      }
      else {
        int oldDotIndex = 0;
        int dotEnd = domain.indexOf('.', oldDotIndex);
        if (dotEnd < 0) {
          return false;
        }
        boolean done = false;
        do {
          if (oldDotIndex == dotEnd) {
            return false;
          }
          if (!Character.isLetter(domain.charAt(oldDotIndex)) &&
              !Character.isDigit(domain.charAt(oldDotIndex))) {
            return false;
          }
          for (int i = oldDotIndex + 1; i < dotEnd - 1; i++) {
            char cur = domain.charAt(i);
            if (!Character.isLetter(cur) &&
                !Character.isDigit(cur) &&
                cur != '-') {
              return false;
            }
          }

          if (!Character.isLetter(domain.charAt(dotEnd - 1)) &&
              !Character.isDigit(domain.charAt(dotEnd - 1))) {
            return false;
          }
          oldDotIndex = dotEnd + 1;
          dotEnd = domain.indexOf('.', oldDotIndex + 1);
        }
        while (dotEnd > 0);
        String ext = domain.substring(oldDotIndex);
        if (ext == null || ext.length() == 0) {
          return false;
        }
        else if (
            // 检查域名:参见 RFC1591标准
            !ext.equalsIgnoreCase("com") &&
            !ext.equalsIgnoreCase("edu") &&
            !ext.equalsIgnoreCase("gov") &&
            !ext.equalsIgnoreCase("int") &&
            !ext.equalsIgnoreCase("mil") &&
            !ext.equalsIgnoreCase("net") &&
            !ext.equalsIgnoreCase("org") &&
            !ext.equalsIgnoreCase("arpa") &&
            // 最新 TLDs
            // http://www.icann.org/tlds/
            !ext.equalsIgnoreCase("aero") &&
            !ext.equalsIgnoreCase("biz") &&
            !ext.equalsIgnoreCase("coop") &&
            !ext.equalsIgnoreCase("info") &&
            !ext.equalsIgnoreCase("museum") &&
            !ext.equalsIgnoreCase("name") &&
            !ext.equalsIgnoreCase("pro") &&
            // 国家码
            // http://www.iana.org/cctld/cctld-whois.htm
            // Ascension Island
            !ext.equalsIgnoreCase("ac") &&
            // Andorra
            !ext.equalsIgnoreCase("ad") &&
            // United Arab Emirates
            !ext.equalsIgnoreCase("ae") &&
            // Afghanistan
            !ext.equalsIgnoreCase("af") &&
            // Antigua and Barbuda
            !ext.equalsIgnoreCase("ag") &&
            // Anguilla
            !ext.equalsIgnoreCase("ai") &&
            // Albania
            !ext.equalsIgnoreCase("al") &&
            // Armenia
            !ext.equalsIgnoreCase("am") &&
            // Netherlands Antilles
            !ext.equalsIgnoreCase("an") &&
            // Angola
            !ext.equalsIgnoreCase("ao") &&
            // Antartica
            !ext.equalsIgnoreCase("aq") &&
            // Argentina
            !ext.equalsIgnoreCase("ar") &&
            // American Samoa
            !ext.equalsIgnoreCase("as") &&
            // Austria
            !ext.equalsIgnoreCase("at") &&
            // Australia
            !ext.equalsIgnoreCase("au") &&
            // Aruba
            !ext.equalsIgnoreCase("aw") &&
            // Azerbaijan
            !ext.equalsIgnoreCase("az") &&
            // Bosnia and Herzegovina
            !ext.equalsIgnoreCase("ba") &&
            // Barbados
            !ext.equalsIgnoreCase("bb") &&
            // Bangladesh
            !ext.equalsIgnoreCase("bd") &&
            // Belgium
            !ext.equalsIgnoreCase("be") &&
            // Burkina Faso
            !ext.equalsIgnoreCase("bf") &&
            // Bulgaria
            !ext.equalsIgnoreCase("bg") &&
            // Bahrain
            !ext.equalsIgnoreCase("bh") &&
            // Burundi
            !ext.equalsIgnoreCase("bi") &&
            // Benin
            !ext.equalsIgnoreCase("bj") &&
            // Bermuda
            !ext.equalsIgnoreCase("bm") &&
            // Brunei Darussalam
            !ext.equalsIgnoreCase("bn") &&
            // Bolivia
            !ext.equalsIgnoreCase("bo") &&
            // Brazil
            !ext.equalsIgnoreCase("br") &&
            // Bahamas
            !ext.equalsIgnoreCase("bs") &&
            // Bhutan
            !ext.equalsIgnoreCase("bt") &&
            // Bouvet Island
            !ext.equalsIgnoreCase("bv") &&
            // Botswana
            !ext.equalsIgnoreCase("bw") &&
            // Belarus
            !ext.equalsIgnoreCase("by") &&
            // Belize
            !ext.equalsIgnoreCase("bz") &&
            // Canada
            !ext.equalsIgnoreCase("ca") &&
            // Cocos (Keeling) Islands
            !ext.equalsIgnoreCase("cc") &&
            // Congo, Democratic People's Republic
            !ext.equalsIgnoreCase("cd") &&
            // Central African Republic
            !ext.equalsIgnoreCase("cf") &&
            // Congo, Republic of
            !ext.equalsIgnoreCase("cg") &&
            // Switzerland
            !ext.equalsIgnoreCase("ch") &&
            // Cote d'Ivoire
            !ext.equalsIgnoreCase("ci") &&
            // Cook Islands
            !ext.equalsIgnoreCase("ck") &&
            // Chile
            !ext.equalsIgnoreCase("cl") &&
            // Cameroon
            !ext.equalsIgnoreCase("cm") &&
            // China
            !ext.equalsIgnoreCase("cn") &&
            // Colombia
            !ext.equalsIgnoreCase("co") &&
            // Costa Rica
            !ext.equalsIgnoreCase("cr") &&
            // Cuba
            !ext.equalsIgnoreCase("cu") &&
            // Cap Verde
            !ext.equalsIgnoreCase("cv") &&
            // Christmas Island
            !ext.equalsIgnoreCase("cx") &&
            // Cyprus
            !ext.equalsIgnoreCase("cy") &&
            // Czech Republic
            !ext.equalsIgnoreCase("cz") &&
            // Germany
            !ext.equalsIgnoreCase("de") &&
            // Djibouti
            !ext.equalsIgnoreCase("dj") &&
            // Denmark
            !ext.equalsIgnoreCase("dk") &&
            // Dominica
            !ext.equalsIgnoreCase("dm") &&
            // Dominican Republic
            !ext.equalsIgnoreCase("do") &&
            // Algeria
            !ext.equalsIgnoreCase("dz") &&
            // Ecuador
            !ext.equalsIgnoreCase("ec") &&
            // Estonia
            !ext.equalsIgnoreCase("ee") &&
            // Egypt
            !ext.equalsIgnoreCase("eg") &&
            // Western Sahara
            !ext.equalsIgnoreCase("eh") &&
            // Eritrea
            !ext.equalsIgnoreCase("er") &&
            // Spain
            !ext.equalsIgnoreCase("es") &&
            // Ethiopia
            !ext.equalsIgnoreCase("et") &&
            // Finland
            !ext.equalsIgnoreCase("fi") &&
            // Fiji
            !ext.equalsIgnoreCase("fj") &&
            // Falkland Islands (Malvina)
            !ext.equalsIgnoreCase("fk") &&
            // Micronesia, Federal State of
            !ext.equalsIgnoreCase("fm") &&
            // Faroe Islands
            !ext.equalsIgnoreCase("fo") &&
            // France
            !ext.equalsIgnoreCase("fr") &&
            // Gabon
            !ext.equalsIgnoreCase("ga") &&
            // Grenada
            !ext.equalsIgnoreCase("gd") &&
            // Georgia
            !ext.equalsIgnoreCase("ge") &&
            // French Guiana
            !ext.equalsIgnoreCase("gf") &&
            // Guernsey
            !ext.equalsIgnoreCase("gg") &&
            // Ghana
            !ext.equalsIgnoreCase("gh") &&
            // Gibraltar
            !ext.equalsIgnoreCase("gi") &&
            // Greenland
            !ext.equalsIgnoreCase("gl") &&
            // Gambia

            !ext.equalsIgnoreCase("gm") &&
            // Guinea
            !ext.equalsIgnoreCase("gn") &&
            // Guadeloupe
            !ext.equalsIgnoreCase("gp") &&
            // Equatorial Guinea
            !ext.equalsIgnoreCase("gq") &&
            // Greece
            !ext.equalsIgnoreCase("gr") &&
            // South Georgia and the South Sandwich Islands
            !ext.equalsIgnoreCase("gs") &&
            // Guatemala
            !ext.equalsIgnoreCase("gt") &&
            // Guam
            !ext.equalsIgnoreCase("gu") &&
            // Guinea-Bissau
            !ext.equalsIgnoreCase("gw") &&
            // Guyana
            !ext.equalsIgnoreCase("gy") &&
            // Hong Kong
            !ext.equalsIgnoreCase("hk") &&
            // Heard and McDonald Islands
            !ext.equalsIgnoreCase("hm") &&
            // Honduras
            !ext.equalsIgnoreCase("hn") &&
            // Croatia/Hrvatska
            !ext.equalsIgnoreCase("hr") &&
            // Haiti
            !ext.equalsIgnoreCase("ht") &&
            // Hungary
            !ext.equalsIgnoreCase("hu") &&
            // Indonesia
            !ext.equalsIgnoreCase("id") &&
            // Ireland
            !ext.equalsIgnoreCase("ie") &&
            // Israel
            !ext.equalsIgnoreCase("il") &&
            // Isle of Man
            !ext.equalsIgnoreCase("im") &&
            // India
            !ext.equalsIgnoreCase("in") &&
            // British Indian Ocean Territory
            !ext.equalsIgnoreCase("io") &&
            // Iraq
            !ext.equalsIgnoreCase("iq") &&
            // Iran (Islamic Republic of)
            !ext.equalsIgnoreCase("ir") &&
            // Iceland
            !ext.equalsIgnoreCase("is") &&
            // Italy
            !ext.equalsIgnoreCase("it") &&
            // Jersey
            !ext.equalsIgnoreCase("je") &&
            // Jamaica
            !ext.equalsIgnoreCase("jm") &&
            // Jordan
            !ext.equalsIgnoreCase("jo") &&
            // Japan
            !ext.equalsIgnoreCase("jp") &&
            // Kenya
            !ext.equalsIgnoreCase("ke") &&
            // Kyrgyzstan
            !ext.equalsIgnoreCase("kg") &&
            // Cambodia
            !ext.equalsIgnoreCase("kh") &&
            // Kiribati
            !ext.equalsIgnoreCase("ki") &&
            // Comoros
            !ext.equalsIgnoreCase("km") &&
            // Saint Kitts and Nevis
            !ext.equalsIgnoreCase("kn") &&
            // Korea, Democratic People's Republic
            !ext.equalsIgnoreCase("kp") &&
            // Korea, Republic of
            !ext.equalsIgnoreCase("kr") &&
            // Kuwait
            !ext.equalsIgnoreCase("kw") &&
            // Cayman Islands
            !ext.equalsIgnoreCase("ky") &&
            // Kazakhstan
            !ext.equalsIgnoreCase("kz") &&
            // Lao People's Democratic Republic
            !ext.equalsIgnoreCase("la") &&
            // Lebanon
            !ext.equalsIgnoreCase("lb") &&
            // Saint Lucia
            !ext.equalsIgnoreCase("lc") &&
            // Liechtenstein
            !ext.equalsIgnoreCase("li") &&
            // Sri Lanka
            !ext.equalsIgnoreCase("lk") &&
            // Liberia
            !ext.equalsIgnoreCase("lr") &&
            // Lesotho
            !ext.equalsIgnoreCase("ls") &&
            // Lithuania
            !ext.equalsIgnoreCase("lt") &&
            // Luxembourg
            !ext.equalsIgnoreCase("lu") &&
            // Latvia
            !ext.equalsIgnoreCase("lv") &&
            // Libyan Arab Jamahiriya
            !ext.equalsIgnoreCase("ly") &&
            // Morocco
            !ext.equalsIgnoreCase("ma") &&
            // Monaco
            !ext.equalsIgnoreCase("mc") &&
            // Moldova, Republic of
            !ext.equalsIgnoreCase("md") &&
            // Madagascar
            !ext.equalsIgnoreCase("mg") &&
            // Marshall Islands
            !ext.equalsIgnoreCase("mh") &&
            // Macedonia, Former Yugoslav Republic
            !ext.equalsIgnoreCase("mk") &&
            // Mali
            !ext.equalsIgnoreCase("ml") &&
            // Myanmar
            !ext.equalsIgnoreCase("mm") &&
            // Mongolia
            !ext.equalsIgnoreCase("mn") &&
            // Macau
            !ext.equalsIgnoreCase("mo") &&
            // Northern Mariana Islands
            !ext.equalsIgnoreCase("mp") &&
            // Martinique
            !ext.equalsIgnoreCase("mq") &&
            // Mauritania
            !ext.equalsIgnoreCase("mr") &&
            // Montserrat
            !ext.equalsIgnoreCase("ms") &&
            // Malta
            !ext.equalsIgnoreCase("mt") &&
            // Mauritius
            !ext.equalsIgnoreCase("mu") &&
            // Maldives
            !ext.equalsIgnoreCase("mv") &&
            // Malawi
            !ext.equalsIgnoreCase("mw") &&
            // Mexico
            !ext.equalsIgnoreCase("mx") &&
            // Malaysia
            !ext.equalsIgnoreCase("my") &&
            // Mozambique
            !ext.equalsIgnoreCase("mz") &&
            // Namibia
            !ext.equalsIgnoreCase("na") &&
            // New Caledonia
            !ext.equalsIgnoreCase("nc") &&
            // Niger
            !ext.equalsIgnoreCase("ne") &&
            // Norfolk Island
            !ext.equalsIgnoreCase("nf") &&
            // Nigeria
            !ext.equalsIgnoreCase("ng") &&
            // Nicaragua
            !ext.equalsIgnoreCase("ni") &&
            // Netherlands
            !ext.equalsIgnoreCase("nl") &&
            // Norway
            !ext.equalsIgnoreCase("no") &&
            // Nepal
            !ext.equalsIgnoreCase("np") &&
            // Nauru
            !ext.equalsIgnoreCase("nr") &&
            // Niue
            !ext.equalsIgnoreCase("nu") &&
            // New Zealand
            !ext.equalsIgnoreCase("nz") &&
            // Oman
            !ext.equalsIgnoreCase("om") &&
            // Panama
            !ext.equalsIgnoreCase("pa") &&
            // Peru
            !ext.equalsIgnoreCase("pe") &&
            // French Polynesia
            !ext.equalsIgnoreCase("pf") &&
            // Papua New Guinea
            !ext.equalsIgnoreCase("pg") &&
            // Philippines
            !ext.equalsIgnoreCase("ph") &&
            // Pakistan
            !ext.equalsIgnoreCase("pk") &&
            // Poland
            !ext.equalsIgnoreCase("pl") &&
            // St. Pierre and Miquelon
            !ext.equalsIgnoreCase("pm") &&
            // Pitcairn Island
            !ext.equalsIgnoreCase("pn") &&
            // Puerto Rico
            !ext.equalsIgnoreCase("pr") &&
            // Palestinian Territories
            !ext.equalsIgnoreCase("ps") &&
            // Portugal
            !ext.equalsIgnoreCase("pt") &&
            // Palau
            !ext.equalsIgnoreCase("pw") &&
            // Paraguay
            !ext.equalsIgnoreCase("py") &&
            // Qatar
            !ext.equalsIgnoreCase("qa") &&
            // Reunion Island
            !ext.equalsIgnoreCase("re") &&
            // Romania
            !ext.equalsIgnoreCase("ro") &&
            // Russian Federation
            !ext.equalsIgnoreCase("ru") &&
            // Rwanda
            !ext.equalsIgnoreCase("rw") &&
            // Saudi Arabia
            !ext.equalsIgnoreCase("sa") &&
            // Solomon Islands
            !ext.equalsIgnoreCase("sb") &&
            // Seychelles
            !ext.equalsIgnoreCase("sc") &&
            // Sudan
            !ext.equalsIgnoreCase("sd") &&
            // Sweden
            !ext.equalsIgnoreCase("se") &&
            // Singapore
            !ext.equalsIgnoreCase("sg") &&
            // St. Helena
            !ext.equalsIgnoreCase("sh") &&
            // Slovenia
            !ext.equalsIgnoreCase("si") &&
            // Svalbard and Jan Mayen Islands
            !ext.equalsIgnoreCase("sj") &&
            // Slovak Republic
            !ext.equalsIgnoreCase("sk") &&
            // Sierra Leone
            !ext.equalsIgnoreCase("sl") &&
            // San Marino
            !ext.equalsIgnoreCase("sm") &&
            // Senegal
            !ext.equalsIgnoreCase("sn") &&
            // Somalia
            !ext.equalsIgnoreCase("so") &&
            // Suriname
            !ext.equalsIgnoreCase("sr") &&
            // Sao Tome and Principe
            !ext.equalsIgnoreCase("st") &&
            // El Salvador
            !ext.equalsIgnoreCase("sv") &&
            // Syrian Arab Republic
            !ext.equalsIgnoreCase("sy") &&
            // Swaziland
            !ext.equalsIgnoreCase("sz") &&
            // Turks and Caicos Islands
            !ext.equalsIgnoreCase("tc") &&
            // Chad
            !ext.equalsIgnoreCase("td") &&
            // French Southern Territories
            !ext.equalsIgnoreCase("tf") &&
            // Togo
            !ext.equalsIgnoreCase("tg") &&
            // Thailand
            !ext.equalsIgnoreCase("th") &&
            // Tajikistan
            !ext.equalsIgnoreCase("tj") &&
            // Tokelau
            !ext.equalsIgnoreCase("tk") &&
            // Turkmenistan
            !ext.equalsIgnoreCase("tm") &&
            // Tunisia
            !ext.equalsIgnoreCase("tn") &&
            // Tonga
            !ext.equalsIgnoreCase("to") &&
            // East Timor
            !ext.equalsIgnoreCase("tp") &&
            // Turkey
            !ext.equalsIgnoreCase("tr") &&
            // Trinidad and Tobago
            !ext.equalsIgnoreCase("tt") &&
            // Tuvalu
            !ext.equalsIgnoreCase("tv") &&
            // Taiwan
            !ext.equalsIgnoreCase("tw") &&
            // Tanzania
            !ext.equalsIgnoreCase("tz") &&
            // Ukraine
            !ext.equalsIgnoreCase("ua") &&
            // Uganda
            !ext.equalsIgnoreCase("ug") &&
            // United Kingdom
            !ext.equalsIgnoreCase("uk") &&
            // US Minor Outlying Islands
            !ext.equalsIgnoreCase("um") &&
            // United States
            !ext.equalsIgnoreCase("us") &&
            // Uruguay
            !ext.equalsIgnoreCase("uy") &&
            // Uzbekistan
            !ext.equalsIgnoreCase("uz") &&
            // Holy See (City Vatican State)
            !ext.equalsIgnoreCase("va") &&
            // Saint Vincent and the Grenadines
            !ext.equalsIgnoreCase("vc") &&
            // Venezuela
            !ext.equalsIgnoreCase("ve") &&
            // Virgin Islands (British)
            !ext.equalsIgnoreCase("vg") &&
            // Virgin Islands (USA)
            !ext.equalsIgnoreCase("vi") &&
            // Vietnam
            !ext.equalsIgnoreCase("vn") &&
            // Vanuatu
            !ext.equalsIgnoreCase("vu") &&
            // Wallis and Futuna Islands
            !ext.equalsIgnoreCase("wf") &&
            // Western Samoa
            !ext.equalsIgnoreCase("ws") &&
            // Yemen
            !ext.equalsIgnoreCase("ye") &&
            // Mayotte
            !ext.equalsIgnoreCase("yt") &&
            // Yugoslavia
            !ext.equalsIgnoreCase("yu") &&
            // South Africa
            !ext.equalsIgnoreCase("za") &&
            // Zambia
            !ext.equalsIgnoreCase("zm") &&
            // Zaire
            !ext.equalsIgnoreCase("zr") &&
            // Zimbabwe?
            !ext.equalsIgnoreCase("zw")) {
          return false;
        }
      }
    }

    return true;
  }


  public static String getExtension(File f)
   {
     String ext = null;
     String s = f.getName();
     int i = s.lastIndexOf('.');
     if (i > 0 && i < s.length() - 1)
     {
       ext = s.substring(i+1).toLowerCase();
     }
     return ext;
   }


     // delete by gaoyanzhi, 20080303,  for compile not link oracle.sql.CLOB---------->
   public static String combineRight(String potenceall)
   {
     if(potenceall == null || "".equals(potenceall.trim()))
       return potenceall;
     String strs[] = potenceall.split("\\|");
     int len = strs.length;
     if(len == 1)
       return potenceall;

     String retright = strs[0];
     String curr = null;
     char chars[] = new char[4];
     for(int i=0; i<len; i++)
     {
       curr = strs[i];
       if('1' ==curr.charAt(0) || '1' ==retright.charAt(0))
       {
         chars[0]='1';
       }
       else
         chars[0]='0';
       if('1' ==curr.charAt(1) || '1' ==retright.charAt(1))
       {
         chars[1]='1';
       }
       else
         chars[1]='0';
       if('1' ==curr.charAt(2) || '1' ==retright.charAt(2))
       {
         chars[2]='1';
       }
       else
         chars[2]='0';
       if('1' ==curr.charAt(3) || '1' ==retright.charAt(3))
       {
         chars[3]='1';
       }
       else
         chars[3]='0';

       retright = new String(chars);
     }
     return retright;
   }
//   //<add by yuxxa for bug fix Frame00001318----------------------------------
//   // date = "2006-2-20">
//   public static void emptyCatch() {
//     try {
//    	 getWorkFlowServer().emptyCache();
//     }
//     catch (Exception e) {
//       e.printStackTrace();
//     }
//   }
//   //</add-------------------------------------------------------------->


   ////////////////////////////////////////////////////////////////////////////
   // <!-- add by gaoyanzhi,20061025, for bs and cs
   ////////////////////////////////////////////////////////////////////////////
   public static ImageIcon getImageIcon(String iiName)
   {
     try
     {
       URL pathurl = Util.class.getResource("/images/" + iiName);
       Image saveMage = Toolkit.getDefaultToolkit().getImage(pathurl);
       ImageIcon ii = new ImageIcon(saveMage);
       return ii;
     }
     catch(Exception ex)
     {
       System.out.println("缺少图标文件，名称为 ["+ iiName+"]");
       ex.printStackTrace();
       //Util.logError(ex);
       //Util.log.error(ex);
       return null;
     }
   }
   public static Image getImage(String iiName)
   {
     try
     {
       URL pathurl = Util.class.getResource("/images/" + iiName);
       Image saveMage = Toolkit.getDefaultToolkit().getImage(pathurl);
       return saveMage;
     }
     catch(Exception ex)
     {
       System.out.println("缺少图标文件，名称为 ["+ iiName+"]");
       ex.printStackTrace();
       //Util.logError(ex);
       //Util.log.error(ex);
       return null;
     }
   }


   ////////////////////////////////////////////////////////////////////////////
   // add by gaoyanzhi,20061025, for bs and cs----------->
   ////////////////////////////////////////////////////////////////////////////

   //<add by yuxxa 2007-08-10==================================================>
   //判断字符串是否是整型串
   static public boolean isNumeric(String str) {
       Pattern pattern = Pattern.compile("[0-9]*");
       Matcher isNum = pattern.matcher(str);
       if (!isNum.matches()) {
           return false;
       }
       return true;
   }

   // 判断字符串是否正整数
   static public boolean isPNumeric(String str) {
     if(str == null || "".equals(str.trim()))
       return false;
       Pattern pattern = Pattern.compile("[0-9]*");
       Matcher isNum = pattern.matcher(str);
       if (!isNum.matches()) {
           return false;
       }
       if (Integer.parseInt(str)<=0)
         return false;

       return true;
   }
   
   public static boolean isVarName4Xml(String varName)
   {
	   //String regex = "[0-9]*[a-zA-Z]*";
	   String headvar = varName.substring(0,1);
	   String regex = "[0-9]";
	   Pattern p = Pattern.compile(regex);
	   Matcher m = p.matcher(headvar);
	   boolean b = m.matches();
	   return b;
   }
   public static void main(String[] args)
   {
	   Util.isVarName4Xml("090ayui900");
	   System.out.println("==============");
	   
   }
}
